package com.qfmy.app.controller.community;

import com.qfmy.app.service.community.PostCommentService;
import com.qfmy.common.result.Result;
import com.qfmy.model.entity.community.PostComment;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.app.controller.community
 * @date 2025/4/17
 * @description 帖子的评论
 */
@RestController
@RequestMapping("/app/postComment")
@SuppressWarnings("all")
public class PostCommentController {

    /**
     * 注入service
     */
    @Resource
    private PostCommentService postCommentService;

    /**
     * 添加帖子评论
     */
    @RequestMapping("/addPostComment")
    public Result addPostComment(@RequestParam Integer postId, @RequestParam String content) {
         postCommentService.addPostComment(postId, content);
         return Result.ok();
    }

    /**
     * 分页获取帖子的评论
     */
    @RequestMapping("/getPostComment")
    public Result<List<PostComment>> getPostComment(@RequestParam Integer pageNum, @RequestParam Integer size, @RequestParam Integer postId) {
         List<PostComment> postComments =   postCommentService.getPostComment(pageNum, size, postId);
         return Result.ok(postComments);
    }



}
